<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!-- 页面头部 -->
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script>
    $(function () {
        ajax();
        setInterval("ajax()",5000);
    })

    function ajax() {
        $.ajax({
            url:"http://localhost:8080/erp/bus/task/allTask",
            data:{"userId":${sessionScope.get("userInfo").userId}},
            type:'Post',
            dataType:"json",
            success:function (data) {
                $("#numTask").text(data.length);
                $("#taskY").text("你有"+data.length+"封邮件");
                var str='';
                for(var i=0;i<data.length;i++){
                    strTime=new Date().get;
                    str+="<li><a onclick=\"srcTask('"+data[i].href+"')\"><div class=\"pull-left\">\n" +
                        "<img src=\"${pageContext.request.contextPath}/img/user2-160x160.jpg\"\n" +
                        "class=\"img-circle\" alt=\"User Image\">\n" +
                        "</div>\n" +
                        "<h4>\n" +
                        ""+data[i].taskType+"\n" +
                        "<small><i class=\"fa fa-clock-o\"></i>"+data[i].createTime+"</small>\n" +
                        "</h4>\n" +
                        "<p>"+data[i].taskName+"</p></a></li>";
                }
                $("#ulTask").html(str);
            }
        })
    }

    function srcTask(TaskHref) {
        $("#contextFrame").attr("src",TaskHref);
    }
</script>
<header class="main-header">
    <!-- Logo -->
    <a href="all-admin-index.html" class="logo"> <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini"><b>数据</b></span> <!-- logo for regular state and mobile devices -->
        <span class="logo-lg"><b>数据</b>后台管理</span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
        </a>

        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
                <li class="dropdown messages-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-envelope-o" id="Task"></i>
                        <span class="label label-success" id="numTask">4</span>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="header" id="taskY">你有4个邮件</li>
                        <li>
                            <!-- inner menu: contains the actual data -->
                            <ul class="menu" id="ulTask">
                            </ul>
                        </li>
                    </ul>
                </li>
                <li class="dropdown user user-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <img src="${pageContext.request.contextPath}/img/user2-160x160.jpg" class="user-image"
                             alt="User Image">
                        <span class="hidden-xs">
                            <security:authentication property="principal.username"/>
                        </span>
                    </a>
                    <ul class="dropdown-menu">
                        <!-- User image -->
                        <li class="user-header">
                            <img src="${pageContext.request.contextPath}/img/dj-128x128.gif" class="img-circle" alt="User Image">
                        </li>
                        <!-- Menu Footer-->
                        <li class="user-footer">
                            <div class="pull-left">
                                <a href="${pageContext.request.contextPath}/templates/system/user/changePwd.jsp" class="btn btn-default btn-flat">修改密码</a>
                            </div>
                            <div class="pull-right">
                                <a href="${pageContext.request.contextPath}/login.jsp" class="btn btn-default btn-flat">注销</a>
                            </div>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
</header>
<!-- 页面头部 /-->